﻿
package extremefx.storage {
	import flash.net.URLLoader;	

	/**
	 * @author Marcelo Volmaro
	 */
	internal class GLoader extends QeuedItem {
		protected var _loader:URLLoader;
		protected var _fmt:String;

		public function GLoader(pUrl:*) {
			super(pUrl, null);
		}

		override public function start():Boolean {
			var r:Boolean = super.start();
			if (r){
				_loader = new URLLoader();
				_addHandlers(_loader);
				_loader.dataFormat = _fmt;//URLLoaderDataFormat.TEXT;
				_loader.load(_loadUrl);
			}
			
			return r;
		}

		override public function stop():Boolean {
			var r:Boolean = super.stop();
			if (r){
				try{
					_loader.close();
				} catch(error:Error){}
			}
			
			return r;
		}
		
		override public function dispose():void {
			super.dispose();
			_loader = null;
		}
	}
}
